/*
@Time : 2020/8/6 12:09
@Author : lym
@File : JsonResponse
@Software: GoLand
*/
package response

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

type JsonResponse struct {
	Code int         `json:"code"`
	Data interface{} `json:"data"`
	Msg  string      `json:"msg"`
}

func Ok(ctx *gin.Context, code int, data interface{}, msg string) {
	ctx.JSON(http.StatusOK, JsonResponse{
		Code: code,
		Data: data,
		Msg:  msg,
	})
	return
}

func Bad(ctx *gin.Context, code int, data interface{}, msg string) {
	ctx.JSON(http.StatusOK, JsonResponse{
		Code: code,
		Data: data,
		Msg:  msg,
	})
	return
}

// @Summary 测试接口
// @Description 描述信息
// @Success 200 {object} JsonResponse {"code":200,"data":null,"msg":""}
// @Router /v1/test [get]
func Test(ctx *gin.Context) {
	Ok(ctx, 200, nil, "测试成功")
}
